home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / Python 1.3 / Python 1.3 PPC / Tools / bgen / dlg / tdlg.py < prev   
Encoding:
Python Source  |  1995-10-11  |  748 b   |  34 lines  |  [TEXT/PYTH]

  1. # Function to display a message and wait for the user to hit OK.
  2. # This uses a DLOG resource with ID=256 which is part of the standard
  3. # Python library.
  4. # The ID can be overridden by passing a second parameter.
  5.  
  6. import addpack
  7. addpack.addpack(':Tools:bgen:evt')
  8.  
  9. from Dlg import *
  10. from Events import *
  11. import string
  12.  
  13. ID = 256
  14.  
  15. def f(d, event):
  16.     what, message, when, where, modifiers = event
  17.     if what == keyDown and modifiers & cmdKey and \
  18.        string.lower(chr(message & charCodeMask)) == 'o':
  19.         return 1
  20.  
  21. def message(str = "Hello, world!", id = ID):
  22.     d = GetNewDialog(id, -1)
  23.     tp, h, rect = d.GetDialogItem(2)
  24.     SetDialogItemText(h, str)
  25.     while 1:
  26.         n = ModalDialog(f)
  27.         if n == 1: break
  28.  
  29. def test():
  30.     message()
  31.  
  32. if __name__ == '__main__':
  33.     test()
  34.